﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CE.iPhone.PList;
namespace cczEdit.CommonInstructComposite
{
    public partial class AddCommonInstruct : Form
    {
        UserControl curUserControl; 
        public AddCommonInstruct()
        {
            InitializeComponent();
            comboBox1.SelectedIndex = 0;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ICommonInstruct ucciInterface = (ICommonInstruct)curUserControl;
            PListDict dict = ucciInterface.CreatResultDict();
            if (dict == null)
                return;
            Form1 mainForm = (Form1)this.Owner;

            TreeNode node = mainForm.ucDrama.CreateTriggerSectionNode(dict); ;
            mainForm.ucDrama.addSectionCode(dict, node);            
            this.Hide();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Controls.Remove(curUserControl);
            if (comboBox1.SelectedIndex == 0)
            {
                curUserControl = new UCCIUnitExit();
            }
            else if (comboBox1.SelectedIndex == 1)
            {
                curUserControl = new UCCIGetItem();
            }
            else if (comboBox1.SelectedIndex == 2)
                curUserControl = new UCCIUnitNeighbor();
            AddCurUserControl();
        }
        private void AddCurUserControl()
        {
            this.curUserControl.Location = new System.Drawing.Point(30, 64);
            this.curUserControl.Size = new System.Drawing.Size(480, 320);
            this.curUserControl.TabIndex = 1;
            this.Controls.Add(curUserControl);
        }

       
    }
}
